<template>
  <el-table border
            :data="ruleForm.collectResults">
    <el-table-column prop="optionsKey" label="最低分数" width="100">
      <template #default="scope">
        <el-input type="text" v-model="scope.row.minScore"/>
      </template>
    </el-table-column>
    <el-table-column prop="optionsTitle" label="最高分数" width="100">
      <template #default="scope">
        <el-input type="text" v-model="scope.row.maxScore"/>
      </template>
    </el-table-column>
    <el-table-column prop="optionVal" label="结果说明" width="200">
      <template #default="scope">
        <el-input type="textarea" v-model="scope.row.resultTitle"/>
      </template>
    </el-table-column>
    <el-table-column prop="optionVal" label="结果描述">
      <template #default="scope">
        <el-input v-model="scope.row.resultDesc" type="textarea"/>
      </template>
    </el-table-column>
    <el-table-column fixed="right" label="操作" width="100" show-overflow-tooltip>
      <template #header>
        <el-button :icon="Plus" :key="'primary'" type="primary" size="small" link @click="addDialog">新增</el-button>
      </template>
      <template #default="scope">
        <el-button link :icon="Delete" size="small" type="danger" @click.prevent="deleteRow(scope.$index)">删除
        </el-button>
        <!--        <el-button link :icon="Edit" size="small" @click="editDialog(scope.row)">编辑</el-button>-->
      </template>
    </el-table-column>
  </el-table>
</template>

<script lang="ts" setup>
import {ElTable} from 'element-plus'
import {onMounted, ref} from 'vue'
import {Delete, Plus} from '@element-plus/icons-vue'
import {DepressOptions} from "@/apis/model/depress/DepressOptionsModel";
import {DepressQuestion} from "@/apis/model/depress/DepressQuestionModel";
import {DepressCollect} from "@/apis/model/depress/DepressCollectModel";
import {DepressCollectResult} from "@/apis/model/depress/DepressCollectResultModel";

interface Props {
  questionId: number,
  ruleForm: DepressCollect,
}

// 传递过来的参数
const props = defineProps<Props>();

// 加载数据
const addDataType = ref('add');

/**
 * 添加弹出
 */
const addDialog = () => {
  props.ruleForm.collectResults.push({} as DepressCollectResult);
}

const deleteRow = (index: number) => {
  props.ruleForm.collectResults.splice(index, 1)
}

onMounted(() => {
})
</script>

<style>
</style>
